﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.Threading;
using GTServices.Model.CoRoutine;
using Caliburn.Micro;
using GTServices.Entities;
using GTServices.Model.Extensions;
using GTServices.Model.Models;
using System.IO;
using System.Data.Entity.Infrastructure;
using System.Data.Entity;
using System.Data.SqlServerCe;


namespace GTServices.Model
{
    public class GTApplication
    {
        #region Singleton
        private static GTApplication _instance;

        public static GTApplication Instance
        {
            get
            {
                lock (_lok)
                {
                    if (_instance == null)
                    {

                        _instance = new GTApplication();

                    }
                }
                return _instance;
            }
        }

        private static object _lok = new object();
        #endregion

        //Dealing with the core model logic for Greping. 
        public GrepModel GrepModel { get; set; }
        
        //Deals with the files, loading, getting, filtering, etc. 
        public FileManagerModel FilesModel { get; set; }

        //Data Access and stuffs. 
        public DataModel DataModel { get; set; } 

        private GTApplication()
        {
            BootStrap(); 
        }

        internal virtual void BootStrap()
        {
                this.GrepModel = new GrepModel();
            //Get the default Database path. 
            string defaultDatabase = Properties.Settings.Default.DefaultDatabase; 

        
            this.DataModel = new DataModel(defaultDatabase);
            this.FilesModel = new FileManagerModel()
            {
                 FileInfos = DataModel.FileInfos
            };

            this.GrepModel.FilesModel = this.FilesModel;
            this.GrepModel.DataModel = this.DataModel;
        }

      

        
    }
}
